import request from '@/utils/request'
// import qs from 'qs'

// 告警配置

// 是否启用监控告警
export function switchAlert (params) {
  var data = fromData(params)
  return request({
    url: '/alert/switch',
    method: 'post',
    data
  })
}

// 获取smtp服务器配置
export function getSmtpInfo (params) {
  var data = fromData(params)
  return request({
    url: '/alert/getSmtpInfo',
    method: 'post',
    data
  })
}

// 获取监控告警状态
export function getAlertStatus (params) {
  var data = fromData(params)
  return request({
    url: '/alert/getAlertStatus',
    method: 'post',
    data
  })
}

// 设置smtp服务器设置
export function setSmtp (params) {
  var data = fromData(params)
  return request({
    url: '/alert/setSmtp',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
